package cn.com.allunion.sms.service.mybatis.impl;

import cn.com.allunion.sms.mapper.TelaccsegmentMapper;
import cn.com.allunion.sms.pojo.Telaccsegment;
import cn.com.allunion.sms.pojo.TelaccsegmentExample;
import cn.com.allunion.sms.service.mybatis.TelaccsegmentService;
import com.github.pagehelper.PageHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 过滤手机号码 业务逻辑接口实现类
 * Created by YangJie on 2016/4/13.
 */
@Service
public class TelaccsegmentServiceImpl implements TelaccsegmentService {

    private static final Logger LOGGER = LoggerFactory.getLogger(TelaccsegmentServiceImpl.class) ;

    @Autowired
    TelaccsegmentMapper telaccsegmentMapper ;

    @Override
    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    public List<Telaccsegment> findTelaccsegment(String number) {
        LOGGER.debug("number.substring(0, 5)" + number.substring(0, 5));

        TelaccsegmentExample example = new TelaccsegmentExample() ;
        TelaccsegmentExample.Criteria criteria = example.createCriteria();
        criteria.andAccSegmentLike(number.substring(0, 5)+"%") ;
        PageHelper.startPage(1, 5) ;
        return telaccsegmentMapper.selectByExample(example);
    }
}
